          	<?php
			
			ob_start();
			session_start();
			$username = $_POST['username'];
			$password = $_POST['password'];
			$submit = $_POST['submit'];
			require('../../connect.php');
				if (isset($submit))
				{
					if (($username != "") and ($password != ""))
					{
						$login = mysql_query("SELECT * FROM customer WHERE customer_username = '$username'");//customer login
						$login1 = mysql_num_rows($login); 
						$login2 = mysql_fetch_array($login);
						
						$login_admin = mysql_query("SELECT * FROM administrator WHERE username = '$username'");//customer login
						$login_rows_admin = mysql_num_rows($login_admin); 
						$l = mysql_fetch_array($login_admin);
						
						$login_staff = mysql_query("SELECT * FROM staff WHERE username = '$username'");//staff login
						$login_rows_staff = mysql_num_rows($login_staff); 
						$ls = mysql_fetch_array($login_staff);
						
						if ($login1 == '1')
						{
							if ($password == $login2['customer_password'])
							{
							$_SESSION['customer'] = $username;
							header("Location: mymessages.php");
							exit();
							}
							else
							echo "<div id='loginError'><b>Error:</b> Wrong Password</div>";
						}
						
						else if ($login_rows_admin == '1')
						{
							if ($password == $l['password'])
							{
							$_SESSION['administrator'] = $username;
							header("Location: admin.php");
							exit();
							}
							else
							echo "<div id='loginError'><b>Error:</b> Wrong Password</div>";
						}
						
						else if ($login_rows_staff == '1')
						{
							if ($password == $ls['password'])
							{
							$_SESSION['staff'] = $username;
							header("Location: staff.php");
							exit();
							}
							else
							echo "<div id='loginError'><b>Error:</b> Wrong Password</div>";
						}
						else
						echo "<div id='loginError'><b>Error:</b> Username does not exist</div>";
					}
					else
					echo "<div id='loginError'><b>Error:</b> Please enter your username and password</div>";
					ob_end_flush();	
				}
				?>